 $(document).ready(function(){

    
   

 });
 function address_province(url,id,p,c,a){
     if(!id)  id=0;
     $.post(url,{id:id},function(data){
        var content="";
        var selected="";
        data=eval("("+data+")");
        for(var i=0; i<data.length;i++){
            selected=data[i]['addr_id']==p?"selected":"";
            content=content+'<option value='+data[i]['addr_id']+' '+selected+' >'+data[i]['addr_name']+'</option>';
        }
        $("select[name='province']").html(content);
        address_city(url,data[0]['addr_id'],p,c,a);
     });
     
}

function address_city(url,id,p,c,a){
        if(p) id=p;
        $.post(url,{id:id},function(data){
        var content="";
        var selected="";
        data=eval("("+data+")");
        for(var i=0; i<data.length;i++){
            selected=data[i]['addr_id']==c?"selected":"";
            content=content+'<option value='+data[i]['addr_id']+' '+selected+' >'+data[i]['addr_name']+'</option>';
        }
        $("select[name='city']").html(content);
        address_area(url,data[0]['addr_id'],c,a);
     });
}

function address_area(url,id,c,a){
        if(c) id=c;
        $.post(url,{id:id},function(data){
        var content="";
        var selected="";
        data=eval("("+data+")");
        for(var i=0; i<data.length;i++){
            selected=data[i]['addr_id']==a?"selected":"";
            content=content+'<option value='+data[i]['addr_id']+' '+selected+' >'+data[i]['addr_name']+'</option>';
        }
        $("select[name='area']").html(content);

     });
}